/*
 * #%L
 * SwiftUICommonUtilities
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
/**
 * 
 */
package com.linkwithweb.products.swiftui.dataobject;

/**
 * 
 * DROP TABLE IF EXISTS `automata`.`frm_report_columns`; CREATE TABLE
 * `automata`.`frm_report_columns` ( `COLUMN_KEY` int(10) unsigned NOT NULL
 * AUTO_INCREMENT, `COLUMN_ID` varchar(45) DEFAULT NULL, `COLUMN_NAME`
 * varchar(45) DEFAULT NULL, `REPORT_ID` varchar(45) DEFAULT NULL,
 * `COLUMN_DESCRIPTION` varchar(45) DEFAULT NULL, `COLUMN_LABEL` varchar(45)
 * DEFAULT NULL, `COLUMN_DEFAULT_VALUE` varchar(45) DEFAULT NULL, `COLUMN_TYPE`
 * varchar(45) DEFAULT NULL, `COLUMN_GROUP` varchar(45) DEFAULT NULL,
 * `COLUMN_FORMULAE` varchar(45) DEFAULT NULL, `EDITABLE` tinyint(1) NOT NULL,
 * `DISPLAYABLE` tinyint(1) NOT NULL, `TRUE_VALUE` varchar(45) DEFAULT NULL,
 * `FALSE_VALUE` varchar(45) DEFAULT NULL, `COLUMN_DEFAULT_FORMAT` varchar(45)
 * DEFAULT NULL, `IS_FILTER_ENABLED` tinyint(1) NOT NULL, `DISPLAY_WIDTH`
 * int(10) unsigned NOT NULL, `HYPERLINK_TEXT` varchar(100) NOT NULL,
 * `IS_ACTIVE` tinyint(1) NOT NULL, `IDENTIFIER` varchar(45) DEFAULT NULL,
 * `IDENTIFIER_ROLE` varchar(45) DEFAULT NULL, `CREATED_BY` int(10) unsigned NOT
 * NULL, `CREATED_DATE` datetime NOT NULL, `MODIFIED_BY` int(10) unsigned NOT
 * NULL, `MODIFIED_DATE` datetime NOT NULL, `FILTER_TYPE` varchar(5) DEFAULT
 * NULL, PRIMARY KEY (`COLUMN_KEY`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 * 
 * @author ashwin kumar
 * 
 */
public class FrameworkReportColumn extends BaseDataObject {
	private long columnKey = -1;
	private String columnId = "";
	private String columnName = "";
	private String reportId = "";
	private String columnDescription = "";
	private String columnLabel = "";
	private String columnDefaultValue = "";
	private String columnType = "";
	private String columnGroup = "";
	private int columnOrder = 1;
	private String columnFormulae = "";
	private boolean editable = false;
	private boolean displayable = true;
	private String trueValue = "";
	private String falseValue = "";
	private String columnDefaultFormat = "";
	private boolean filterEnabled = true;
	private int displayWidth = 30;
	private String hyperlinkText = "";
	private String filterType = "";
	private boolean isNullable = true;
	private String txtAreaRows = "";
	private String txtAreaCols = "";
	private Integer precision = 0;
	private Integer scale = 0;

	/**
	 * @return the columnKey
	 */
	public long getColumnKey() {
		return columnKey;
	}

	/**
	 * @param columnKey
	 *            the columnKey to set
	 */
	public void setColumnKey(long columnKey) {
		this.columnKey = columnKey;
	}

	/**
	 * @return the columnId
	 */
	public String getColumnId() {
		return columnId;
	}

	/**
	 * @param columnId
	 *            -
	 *            the columnId to set
	 */
	public void setColumnId(String columnId) {
		this.columnId = columnId;
	}

	/**
	 * @return the columnName
	 */
	public String getColumnName() {
		return columnName;
	}

	/**
	 * @param columnName
	 *            the columnName to set
	 */
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	/**
	 * @return the reportId
	 */
	public String getReportId() {
		return reportId;
	}

	/**
	 * @param reportId
	 *            the reportId to set
	 */
	public void setReportId(String reportId) {
		this.reportId = reportId;
	}

	/**
	 * @return the columnDescription
	 */
	public String getColumnDescription() {
		return columnDescription;
	}

	/**
	 * @param columnDescription
	 *            the columnDescription to set
	 */
	public void setColumnDescription(String columnDescription) {
		this.columnDescription = columnDescription;
	}

	/**
	 * @return the columnLabel
	 */
	public String getColumnLabel() {
		return columnLabel;
	}

	/**
	 * @param columnLabel
	 *            the columnLabel to set
	 */
	public void setColumnLabel(String columnLabel) {
		this.columnLabel = columnLabel;
	}

	/**
	 * @return the columnDefaultValue
	 */
	public String getColumnDefaultValue() {
		return columnDefaultValue;
	}

	/**
	 * @param columnDefaultValue
	 *            the columnDefaultValue to set
	 */
	public void setColumnDefaultValue(String columnDefaultValue) {
		this.columnDefaultValue = columnDefaultValue;
	}

	/**
	 * @return the columnType
	 */
	public String getColumnType() {
		return columnType;
	}

	/**
	 * @param columnType
	 *            the columnType to set
	 */
	public void setColumnType(String columnType) {
		this.columnType = columnType;
	}

	/**
	 * @return the columnGroup
	 */
	public String getColumnGroup() {
		return columnGroup;
	}

	/**
	 * @param columnGroup
	 *            the columnGroup to set
	 */
	public void setColumnGroup(String columnGroup) {
		this.columnGroup = columnGroup;
	}

	/**
	 * @return the columnOrder
	 */
	public int getColumnOrder() {
		return columnOrder;
	}

	/**
	 * @param columnOrder
	 *            the columnOrder to set
	 */
	public void setColumnOrder(int columnOrder) {
		this.columnOrder = columnOrder;
	}

	/**
	 * @return the columnFormulae
	 */
	public String getColumnFormulae() {
		return columnFormulae;
	}

	/**
	 * @param columnFormulae
	 *            the columnFormulae to set
	 */
	public void setColumnFormulae(String columnFormulae) {
		this.columnFormulae = columnFormulae;
	}

	/**
	 * @return the editable
	 */
	public boolean isEditable() {
		return editable;
	}

	/**
	 * @param editable
	 *            the editable to set
	 */
	public void setEditable(boolean editable) {
		this.editable = editable;
	}

	/**
	 * @return the displayable
	 */
	public boolean isDisplayable() {
		return displayable;
	}

	/**
	 * @param displayable
	 *            the displayable to set
	 */
	public void setDisplayable(boolean displayable) {
		this.displayable = displayable;
	}

	/**
	 * @return the trueValue
	 */
	public String getTrueValue() {
		return trueValue;
	}

	/**
	 * @param trueValue
	 *            the trueValue to set
	 */
	public void setTrueValue(String trueValue) {
		this.trueValue = trueValue;
	}

	/**
	 * @return the falseValue
	 */
	public String getFalseValue() {
		return falseValue;
	}

	/**
	 * @param falseValue
	 *            the falseValue to set
	 */
	public void setFalseValue(String falseValue) {
		this.falseValue = falseValue;
	}

	/**
	 * @return the columnDefaultFormat
	 */
	public String getColumnDefaultFormat() {
		return columnDefaultFormat;
	}

	/**
	 * @param columnDefaultFormat
	 *            the columnDefaultFormat to set
	 */
	public void setColumnDefaultFormat(String columnDefaultFormat) {
		this.columnDefaultFormat = columnDefaultFormat;
	}

	/**
	 * @return the filterEnabled
	 */
	public boolean isFilterEnabled() {
		return filterEnabled;
	}

	/**
	 * @param filterEnabled
	 *            the filterEnabled to set
	 */
	public void setFilterEnabled(boolean filterEnabled) {
		this.filterEnabled = filterEnabled;
	}

	/**
	 * @return the displayWidth
	 */
	public int getDisplayWidth() {
		return displayWidth;
	}

	/**
	 * @param displayWidth
	 *            the displayWidth to set
	 */
	public void setDisplayWidth(int displayWidth) {
		this.displayWidth = displayWidth;
	}

	/**
	 * @return the hyperlinkText
	 */
	public String getHyperlinkText() {
		return hyperlinkText;
	}

	/**
	 * @param hyperlinkText
	 *            the hyperlinkText to set
	 */
	public void setHyperlinkText(String hyperlinkText) {
		this.hyperlinkText = hyperlinkText;
	}

	/**
	 * @return the filterType
	 */
	public String getFilterType() {
		return filterType;
	}

	/**
	 * @param filterType
	 *            the filterType to set
	 */
	public void setFilterType(String filterType) {
		this.filterType = filterType;
	}

	/**
	 * @return the isNullable
	 */
	public boolean isNullable() {
		return isNullable;
	}

	/**
	 * @param isNullable
	 *            the isNullable to set
	 */
	public void setNullable(boolean isNullable) {
		this.isNullable = isNullable;
	}

	/**
	 * @return the txtAreaRows
	 */
	public String getTxtAreaRows() {
		return txtAreaRows;
	}

	/**
	 * @param txtAreaRows
	 *            the txtAreaRows to set
	 */
	public void setTxtAreaRows(String txtAreaRows) {
		this.txtAreaRows = txtAreaRows;
	}

	/**
	 * @return the txtAreaCols
	 */
	public String getTxtAreaCols() {
		return txtAreaCols;
	}

	/**
	 * @param txtAreaCols
	 *            the txtAreaCols to set
	 */
	public void setTxtAreaCols(String txtAreaCols) {
		this.txtAreaCols = txtAreaCols;
	}

	/**
	 * @return the precision
	 */
	public Integer getPrecision() {
		return precision;
	}

	/**
	 * @param precision
	 *            the precision to set
	 */
	public void setPrecision(Integer precision) {
		this.precision = precision;
	}

	/**
	 * @return the scale
	 */
	public Integer getScale() {
		return scale;
	}

	/**
	 * @param scale
	 *            the scale to set
	 */
	public void setScale(Integer scale) {
		this.scale = scale;
	}

	/**
	 * @param columnName
	 * @return
	 */
	public static String convertAndGetGenericToDBColumnName(String columnName) {
		return columnName.replaceAll(" ", "").replaceAll(",", "").replaceAll("\\(", "_").replaceAll("\\)", "")
				.replaceAll("\"", "").replaceAll("&", "_").replaceAll("-", "_").replaceAll("\\*", "").replaceAll("\n",
						"").replaceAll("\t", "").replaceAll("\"", "").replaceAll("\\$", "s").replaceAll("/", "_")
				.replaceAll("%", "").replaceAll("\\?", "_");
	}

	public static void main(String[] args) {
		System.out.println(convertAndGetGenericToDBColumnName("%-sdfsf?\""));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((columnName == null) ? 0 : columnName.hashCode());
		result = prime * result + ((reportId == null) ? 0 : reportId.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FrameworkReportColumn other = (FrameworkReportColumn) obj;
		if (columnName == null) {
			if (other.columnName != null)
				return false;
		} else if (!columnName.equals(other.columnName))
			return false;
		if (reportId == null) {
			if (other.reportId != null)
				return false;
		} else if (!reportId.equals(other.reportId))
			return false;
		return true;
	}

}
